import java.util.Random;
import java.util.Scanner;
import java.util.Arrays;

public class NGuessNumber {

    public Object guesslist;
    private int A;
    private int B;
    private Object x;
    private Random ne;
    public void generateAnswer(){
        String number = "";
        Random rd = new Random();
        while (number.length() != 4) {
            String rn = rd.nextInt(10) + "";
            if (number.length()==1){
                if ("0".equals(rn)){
                    continue;
                }
            }
            if (number.indexOf(rn) == -1){
                number += rn;
            }
        }
        System.out.println(number);
    }
    public boolean isWin() {
        return isWin();
    }
    public void answer() {

        int[] newq1 = new int[4];
        for (int i = 0; i < newq1.length; i++) {

            System.out.println("" + A + "A" + B + "B");
            if (A == 4) {
                System.out.println("恭喜你，猜对了!");
                System.out.println("要重新玩一次吗？(Y/N)");
                Scanner sr = new Scanner(System.in);
                String qc = sr.next();
                if (qc.equals("Y") || qc.equals("y")) {
                    x = ne.nextInt(9999 - 1000 + 1) + 1000;
                    System.out.println("游戏玩法:根据提示,猜对4个数字和他们的数据即可获胜!");
                    System.out.println("请输入4个0-9之间的数字:");
                } else {
                    System.out.println("程序结束");
                    System.exit(-1);
                }
            }
        }
    }
    public int[] getPlayerInput(int[] guesslist){

        try {
            Scanner sca = new Scanner(System.in);

            for (int i = 0; i < 4; i++) {
                System.out.println("请输入0-9之间的第" + (i+1) + "个数字：");

                int pl = sca.nextInt();
                //System.out.println(pl);
                if (pl >= 10 || pl < 0) {
                    System.out.print("输入错误，");
                    i=i-1;
                }else {
                    guesslist[i] = pl;
                }
            }
        }catch (Exception e){
            System.out.println("输入错误");
        }

        System.out.println(Arrays.toString(guesslist)+"\n");
        return guesslist;
    }
    public void compareGuessAnswer(){
        Random shuijishu = null;
        int number = shuijishu.nextInt(100)+1;
        int guessnum = new Scanner(System.in).nextInt();
        if(guessnum>=1 && guessnum<=100){
            if(guessnum>number){
                System.out.println("输入数字大了");
            }else if(guessnum<number){
                System.out.println("输入数字小了");
            }else if(guessnum==number){

                System.out.println("猜对了");
            }
        }else{
            System.out.println("数字不正确");
        }

    }
}